//
//  CDHAndZiYuanCell.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/23.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "CDHAndZiYuanCell.h"

@implementation CDHAndZiYuanCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initSubView];
        [self layout];
    }
    return self;
}
- (void)initSubView{
    [self addSubview:self.backView];
    [_backView addSubview:self.leftImageView];
    [_backView addSubview:self.titleLabel];
    [_backView addSubview:self.detailLabel];
    [_backView addSubview:self.dateLabel];
    [_backView addSubview:self.lineView];
}
- (void)layout{
    [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@120);
        make.right.equalTo(@0).offset(-120);
        make.top.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
    [_leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@30);
        make.width.equalTo(@26);
        make.height.equalTo(@30);
        make.centerY.equalTo(self->_backView.mas_centerY);
    }];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_leftImageView.mas_right).offset(10);
        make.top.equalTo(self->_leftImageView.mas_top);
        make.height.equalTo(@15);
        make.right.equalTo(self->_backView.mas_right).offset(-200);
    }];
    [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self->_backView.mas_right).offset(-10);
        make.width.equalTo(@150);
        make.centerY.equalTo(self->_backView.mas_centerY);
        make.height.equalTo(@15);
    }];
    [_detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_titleLabel.mas_left);
        make.width.equalTo(@150);
        make.top.equalTo(self->_titleLabel.mas_bottom);
        make.height.equalTo(@15);
    }];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_backView.mas_left);
        make.right.equalTo(self->_backView.mas_right);
        make.bottom.equalTo(self->_backView.mas_bottom);
        make.height.equalTo(@1);
    }];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (UIView *)backView{
    if (!_backView) {
        UIView *view  = [[UIView alloc]init];
        view.backgroundColor = [UIColor whiteColor];
        _backView = view;
    }
    return _backView;
}
- (UIView *)lineView{
    if (!_lineView) {
        UIView *view  = [[UIView alloc]init];
        view.backgroundColor = LINCOLOR;
        _lineView = view;
    }
    return _lineView;
}
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"新概念 Lesson1";
        label.textColor = TITLECOLOR;
        label.textAlignment = 0;
        label.font = [UIFont systemFontOfSize:14];
        _titleLabel = label;
    }
    return _titleLabel;
}
- (UILabel *)detailLabel{
    if (!_detailLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"82.5MB";
        label.textColor = TITLECOLOR;
        label.textAlignment = 0;
        label.font = [UIFont systemFontOfSize:12];
        _detailLabel = label;
    }
    return _detailLabel;
}
- (UILabel *)dateLabel{
    if (!_dateLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"2019-03-20  10:20";
        label.textColor = [UIColorChange colorwithHexString:@"#999999"];
        label.textAlignment = 2;
        label.font = [UIFont systemFontOfSize:12];
        _dateLabel = label;
    }
    return _dateLabel;
}
- (UIImageView *)leftImageView{
    if (!_leftImageView ) {
        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.image = [UIImage imageNamed:@"zy_collection_xjwjj"];
        _leftImageView  = imageView;
    }
    return _leftImageView;
}
@end
